package org.dreamwork.injection;

import org.dreamwork.cai.tools.Misc;
import org.dreamwork.injection.impl.SimpleObjectContext;

import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.management.ObjectName;

@Resource
public class SimpleInjection {
    private static final String JMX_NAME = "SimpleObjectContext";
    private final ObjectName oName;

    @Resource
    private SimpleObjectContext context;

    public SimpleInjection () {
        oName = Misc.registerJMXService (JMX_NAME, this);
    }

    @PreDestroy
    public void destroy () {
        if (oName != null) {
            Misc.unregisterJMXService (oName);
        }
    }
}